﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LibNiconico.NiconicoApi.Internal;
using LibNiconico.NiconicoApi.Extentions;

namespace LibNiconico.NiconicoApi.Videos.Comments.PostKey
{
    /// <summary>
    /// ニコニコ動画ポストキー取得レスポンス
    /// </summary>
    public sealed class NicoVideoGetPostkeyResponse
    {
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="querys"></param>
        private NicoVideoGetPostkeyResponse(QueryStrings querys) { }
        
        /// <summary>
        /// ポストキー
        /// </summary>
        public string PostKey { get; internal set; }

        /// <summary>
        /// 問い合わせ文字列解析
        /// </summary>
        /// <param name="querys"></param>
        /// <returns></returns>
        public static NicoVideoGetPostkeyResponse Parse(QueryStrings querys)
        {
            NicoVideoGetPostkeyResponse res = new NicoVideoGetPostkeyResponse(querys);
            res.PostKey = (from query in querys
                           where query.Key == "postkey"
                           select query.Value).First() ?? "";

            return res;
        }
    }
}
